package com.example.test.mapper;

import com.example.test.entity.User;
import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper
public interface UserMapper {

    @Select("select * from user")
    List<User> findAll();


    @Select("select * from user where username = #{userName}")
    User findByUserName(String userName);


    //分页查询
    @Select("select * from user limit #{pageNum},#{pageSize}")
    List<User> selectPage(int pageNum,int pageSize);

    //新增数据
    @Insert("insert into user(username,password,email,age,salt) values (#{username},#{password},#{email},#{age},#{salt})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    public int save(User user);

    //删除数据
    @Delete("delete from user where id=#{id}")
    public int delete(int id);

    //根据id查找
    @Select("select * from user where id=#{id}")
    public User get(int user);

    //更新数据
    @Update("update user set username=#{username},password=#{password} where id=#{id} ")
    public int update(User user);

}